#include <bits/stdc++.h>

#define int long long
#define endl "\n"

using namespace std;

struct BIT
{
    vector<int> v;
    BIT(int n)
    {
        v.resize(n+1,0);
    }

    void add_elem(int i,int k)
    {
        while(i<v.size())
        {
            v[i]+=k;
            i+=i&-i;
        }
    }

    int get_sum(int i)
    {
        int res=0;
        while(i>0)
        {
            res+=v[i];
            i-=i&-i;
        }
        return res;
    }

    int get_range(int l,int r)
    {
        return get_sum(r)-get_sum(l-1);
    }

};

inline bool cmp(pair<int,int> a,pair<int,int> b)
{
    return a.second<b.second||(a.second==b.second&&a.first<b.first);
}

void solve()
{
    int n,m,L,V;
    cin>>n>>m>>L>>V;

    vector<int> d(n),v(n),a(n);
    for(int i=0; i<n; ++i)cin>>d[i]>>v[i]>>a[i];

    vector<int> p(m);
    for(int i=0; i<m; ++i)cin>>p[i];

    int cnt=0;
    vector<pair<int,int>> seq;
    for(int i=0; i<n; ++i)
    {
        int leavepos=L;
        if (a[i]!=0)
        {
            if (a[i]<0)
            {
                leavepos=min(leavepos,d[i]-(v[i]*v[i])/(a[i]*2));
            }
        }

        bool flag1=false,flag2=false;
        auto lp=lower_bound(p.begin(),p.end(),d[i]);
        if (lp!=p.end()&&(*lp)<=leavepos)
        {
            if (v[i]*v[i]+2*a[i]*((*lp)-d[i])>V*V)
            {
                flag1=true;
            }
        }

        auto rp=lower_bound(p.rbegin(),p.rend(),leavepos,greater<int>());
        if (rp!=p.rend()&&(*rp)>=d[i])
        {
            if (v[i]*v[i]+2*a[i]*((*rp)-d[i])>V*V)
            {
                flag2=true;
            }
        }

        //int lpv=*lp;
        auto lpr=p.rbegin()+(p.size()-(lp-p.begin())-1);
        //int rpv=*rp;
        auto rpl=p.begin()+(p.size()-(rp-p.rbegin())-1);

        if (flag1||flag2)
        {
            ++cnt;

            if (a[i]>0)
            {
                auto fp=upper_bound(lp,rpl+1,d[i]+(V*V-v[i]*v[i])/(a[i]*2));
                seq.emplace_back(fp-p.begin(),rpl-p.begin());
            }
            else if (a[i]<0)
            {
                auto fp=upper_bound(rp,lpr+1,d[i]+(-V*V+v[i]*v[i]-1)/(-a[i]*2)+1,greater<int>());
                auto fpl=p.begin()+(p.size()-(fp-p.rbegin())-1);
                assert(fpl>=lp);
                seq.emplace_back(lp-p.begin(),fpl-p.begin());
            }
            else
            {
                seq.emplace_back(lp-p.begin(),rpl-p.begin());
            }
        }
    }

    sort(seq.begin(),seq.end(),cmp);

    int remp=0;
    BIT st(m);
    for(auto&i:seq)
    {
        if (st.get_range(i.first+1,i.second+1)>0)continue;
        st.add_elem(i.second+1,1);
        ++remp;
    }

    cout<<cnt<<" "<<m-remp<<endl;

    //for(auto&i:seq)cout<<i.first<<" "<<i.second<<" ";
    //cout<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    int T;
    cin>>T;
    while(T--)solve();



    return 0;
}


